var _api = _interopRequireDefault(require("../../../../utils/api")), _util2 = _interopRequireDefault(require("../util"));

function _interopRequireDefault(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function _objectSpread(t) {
    for (var e = 1; e < arguments.length; e++) {
        var r = null != arguments[e] ? arguments[e] : {}, n = Object.keys(r);
        "function" == typeof Object.getOwnPropertySymbols && (n = n.concat(Object.getOwnPropertySymbols(r).filter(function(e) {
            return Object.getOwnPropertyDescriptor(r, e).enumerable;
        }))), n.forEach(function(e) {
            _defineProperty(t, e, r[e]);
        });
    }
    return t;
}

function _defineProperty(e, t, r) {
    return t in e ? Object.defineProperty(e, t, {
        value: r,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = r, e;
}

Page({
    data: {
        content: ""
    },
    onLoad: function() {
        var e = this.$take("client.remark") || "";
        this.content = e, this.setData({
            content: e
        });
    },
    onSubmit: function(e) {
        var n = this, t = e.detail.value.content;
        if (t === this.content) return this.$route("back");
        var a = this.__query;
        _api.default.minicard.business.update({
            loading: !0,
            data: _objectSpread({
                remark: t
            }, this.__query)
        }).then(function() {
            if (t) {
                var r = "备注：".concat(t);
                _util2.default.addFollowRecord(_objectSpread({
                    content: r
                }, a)).then(function(e) {
                    var t = e.data;
                    return n.$emit("niche.record.update", {
                        content: r,
                        data: t
                    });
                });
            }
            getCurrentPages().slice(-2, -1)[0].setData({
                "client.remark": t
            }), n.$route("back");
        });
    }
});